package fic.storefinder.client.content;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;

public abstract class ContentAbstract extends Composite {
	private final DialogBox dialogBox = new DialogBox();
	private final Label dialogBoxText = new Label();

	public ContentAbstract() {
		// Create the popup dialog box
		dialogBox.setAnimationEnabled(true);
		final Button closeButton = new Button("Bezár");
		// We can set the id of a widget by accessing its Element
		closeButton.getElement().setId("closeButton");
		VerticalPanel dialogVPanel = new VerticalPanel();
		dialogVPanel.addStyleName("dialogVPanel");
		dialogVPanel.add(dialogBoxText);
		dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
		dialogVPanel.add(closeButton);
		dialogBox.setWidget(dialogVPanel);

		// Add a handler to close the DialogBox
		closeButton.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				dialogBox.hide();
			}
		});
	}

	protected void showDialog(String title, String message) {
		dialogBox.setText(title);
		dialogBoxText.setText(message);
		dialogBox.center();
		dialogBox.show();
	}
}
